<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Signin Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
 


<style>
body {
  padding-top: 40px;
  padding-bottom: 40px;
  background-color: #eee;
}

.form-signin {
  max-width: 330px;
  padding: 15px;
  margin: 0 auto;
}
.form-signin .form-signin-heading,
.form-signin .checkbox {
  margin-bottom: 10px;
}
.form-signin .checkbox {
  font-weight: normal;
}
.form-signin .form-control {
  position: relative;
  height: auto;
  -webkit-box-sizing: border-box;
     -moz-box-sizing: border-box;
          box-sizing: border-box;
  padding: 10px;
  font-size: 16px;
}
.form-signin .form-control:focus {
  z-index: 2;
}
.form-signin input[type="email"] {
  margin-bottom: -1px;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}
.form-signin input[type="password"] {
  margin-bottom: 10px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

</style>

  </head>

  <body>

    <div class="container">

      <form class="form-signin" action="/admin/login"   method="post">
        <h2 class="form-signin-heading">${title}登陆</h2>
        <label for="inputEmail" class="sr-only">Email address</label>
        <input type="email" name="email" id="inputEmail" class="form-control"  placeholder="登陆邮箱" required autofocus>
        <label for="inputPassword" class="sr-only">Password</label>
        <input type="password"  name="passwd" id="inputPassword" class="form-control" placeholder="密码" required >
        <div class="checkbox">
          <label>
            <input type="checkbox" value="1" name="saveAccount"> 记住账号
          </label>
        </div>

        <div class="form-group">
            <label for="exampleInputPassword1">校验码</label>
            <input type="text" class="form-control" id="captcha1" placeholder="密码"  name="captcha"  autocomplete="off">
            <img src="/user/captcha" id="captcha2"/> (不区分大小写)
        </div>

        <button class="btn btn-lg btn-primary " type="submit"> 登 陆 </button>
        <a class="btn btn-lg btn-primary" href="/" role="button">返回首页</a>
      </form>

    </div> <!-- /container -->
    
    
    
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    
    
    
  <script type="text/javascript">

  $("#captcha2").click(function(){
      $(this).attr("src","/user/captcha?"+Math.random());
      $("#captcha1").val("");
  });


 $("form").submit(function(e){
    e.preventDefault();
$.post("/admin/login", $("form").serialize(),
          function(data){
          console.log(data); //  2pm
         if(data.status==200){
			window.location.href='/admin/index';
         }else{
            alert(data.status+data.message);
             $("#captcha2").click();
            }
         }, "json");
    
});
</script>  
    
  </body>
</html>
